import request from '@/utils/request'

export function deleteBpm(data) {
    return request({
        url: '/bpm/oa/leave/cancel',
        method: 'DELETE',
        data: data
    })
}

export function add(data) {
    return request({
        url: '/bpm/oa/leave/create',
        method: 'POST',
        data: data
    })
}


export function reject(data) {
    return request({
        url: '/bpm/task/reject',
        method: 'PUT',
        data: data
    })
}

/**
 * 审核通过
 * @param data
 * @returns {*}
 */
export function approve(data) {
    return request({
        url: '/bpm/task/approve',
        method: 'PUT',
        data: data
    })
}

/**
 * 报销查询
 * @param params
 * @returns {*}
 */
export function getMyBpm(params) {
    let url = '/bpm/oa/leave/page?';

    // 将params对象中的属性和值直接拼接到url的后面
    for (const propName of Object.keys(params.params)) {
        const value = params.params[propName];
        if (typeof value !== 'undefined') {
            url += `&${encodeURIComponent(propName)}=${encodeURIComponent(value)}`;
        }
    }

    return request({
        url: url,
        method: 'GET',
    });
}









export function getBpmDetail (id){
    return request({
        url: '/bpm/process-instance/get?id='+ id,
        method: 'GET',
    })
}

/**
 * 我的代办
 * @param params
 * @returns {*}
 */
export function getMyToBpm(params) {
    return request({
        url: '/bpm/task/todo-page',
        method: 'GET',
        params: params
    })
}

/**
 * 我的已办
 * @param params
 * @returns {*}
 */
export function getMyDoneBpm(params) {
    return request({
        url: '/bpm/task/done-page',
        method: 'GET',
        params: params
    })
}

export function getOaDetail (id){
    return request({
        url: '/bpm/oa/leave/get?id='+ id,
        method: 'GET',
    })
}
